/**
 * @(#)SimpleService.java, 十月 28, 2016.
 * <p>
 * Copyright 2016 fenbi.com. All rights reserved.
 * FENBI.COM PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.wasp.collector;

import java.io.IOException;
import java.security.Principal;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;

/**
 * @author zhangpeng
 */
public class Test {
    public static void main(String[] args) throws ClientProtocolException, IOException {
    	CloseableHttpClient httpclient = HttpClients.createDefault();
    	HttpClientContext context = HttpClientContext.create();
    	HttpGet httpget = new HttpGet("http://quote.eastmoney.com/sh603758.html");
    	CloseableHttpResponse response = httpclient.execute(httpget, context);
    	try {
    	    Principal principal = context.getUserToken(Principal.class);
    	    System.out.println(principal);
    	} finally {
    	    response.close();
    	}
    }
}